package com.uzai.console.service.feign.impl;

import com.uzai.common.dto.wxwork.DelWxWorkChannelQrCodeDto;
import com.uzai.common.result.ResponseCode;
import com.uzai.console.common.UzaiRespVo;
import com.uzai.console.dto.feign.wxcontacts.WxContactsRegisterDto;
import com.uzai.console.dto.feign.wxcontacts.WxGroupMemberRegisterDto;
import com.uzai.console.service.feign.WxContactsFeignService;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * @Auther: lucher
 * @Date: 2021/11/24 16:24
 * @Description:
 */
@Component
public class WxContactsFeignFallbackFactory implements FallbackFactory<WxContactsFeignService> {

    private static Logger logger = LoggerFactory.getLogger(WxContactsFeignFallbackFactory.class);

    @Override
    public WxContactsFeignService create(Throwable throwable) {

        logger.error("--通讯录注册调用微服务失败，err={}", throwable);

        return new WxContactsFeignService() {
            @Override
            public UzaiRespVo<Boolean> userreg2(WxContactsRegisterDto wxContactsRegisterDto) {
                UzaiRespVo<Boolean> uzaiRespVo= new UzaiRespVo<>();
                uzaiRespVo.setData(false);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<Long> userreg3(@RequestBody WxGroupMemberRegisterDto wxGroupMemberRegisterDto) {
                UzaiRespVo<Long> uzaiRespVo= new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<Boolean> wxworkDelChanelQrcode(DelWxWorkChannelQrCodeDto delWxWorkChannelQrCodeDto) {
                UzaiRespVo<Boolean> uzaiRespVo= new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }


        };
    }

}
